package MarrySum5;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class MarrySumReducer extends Reducer<Text,MarryCountBean,Text,MarryCountBean> {

    MarryCountBean outValue = new MarryCountBean();

    @Override
    protected void reduce(Text key, Iterable<MarryCountBean> values, Reducer<Text, MarryCountBean, Text, MarryCountBean>.Context context) throws IOException, InterruptedException {
        float totalFmarry = 0;
        float totalRemarry = 0;

        for (MarryCountBean value : values){
            totalFmarry += value.getFmarry();
            totalRemarry += value.getRemarry();
        }

        outValue.set(totalFmarry,totalRemarry);
        context.write(key,outValue);

    }
}
